package com.baizhiedu.rsm.controller;

import com.baizhiedu.rsm.entity.Suggest;
import com.baizhiedu.rsm.service.SuggestService;
import com.baizhiedu.rsm.util.DateConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.DateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author lby
 */
@Controller
@RequestMapping("suggest")
public class SuggestController {
    @Autowired
    private SuggestService suggestService;

    /**
     * 根据时间获取学生提交的意见
     * @param suggestDate
     * @return
     */
    @RequestMapping("showSuggests")
    @ResponseBody
    public List<Suggest> showSuggest(Date suggestDate){
        if(suggestDate == null){
            suggestDate = new DateConverter().convert(DateFormat.getDateInstance().format(new Date()));
        }
        return suggestService.showSuggestByDate(suggestDate);
    }
}
